<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script src="jquery.js"></script>
    <style>
        tr:nth-child(even) {
            background-color: rosybrown;
        }
        table{
            background-color: aqua;
        }
    </style>
</head>
<body>
<h1>直播带货信息列表</h1>
<table border="1">
    <tr>
        <th>主播姓名</th>
        <th>直播平台</th>
        <th>带货产品</th>
        <th>直播时间</th>
        <th>操作</th>
    </tr>

    <c:forEach var="liveCommerce" items="${list}">
        <tr>
            <td>${liveCommerce.streamer}</td>
            <td>${liveCommerce.livePlatform}</td>
            <td>${liveCommerce.product}</td>
            <td>${liveCommerce.liveTime}</td>
            <td>
                <a href="getById?id=${liveCommerce.id}">详情</a>
                <a href="javascript:del(${liveCommerce.id})">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
<a href="add.jsp">添加直播带货信息</a>
<script>
    function del(id) {
        if (confirm('确定删除吗？')) {
            $.post('delete', {id: id}, res => {
                if (res > 0) {
                    alert("删除成功！")
                    location.reload();
                } else {
                    alert('删除失败！')
                }
            })
        }

    }
</script>
</body>
</html>
